# Python 2.6.4
# Project Euler, Problem 26
# Copyright 2010 Talha Zaman

def remcount(n):
    rem = 1
    for i in range(n):
        rem = (rem*10)%n
    match = rem
    count = 0
    rem = (rem*10)%n
    while (rem != match):
        rem = (rem*10)%n
        count += 1
    if rem==0: return 0
    return count

def sieveprimes(limit):
    sieve = [0 for i in range(0, limit)]
    sieve[0] = sieve[1] = 1
    for i in range(2,limit):
        if sieve[i]: continue
        for j in range(2*i, limit, i):
            sieve[j] += 1
    return [x for x in range(limit) if sieve[x]==0]

mcount, mi = 0, 0
p = sieveprimes(1000)
for i in p:
    count = remcount(i)
    if mcount < count: mcount, mi = count, i

print mcount, mi

